﻿<!doctype html>
<html>
<head>
    <title>SpreadJS - Bullet Sparkline</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <link href="../../../external/spreadjs/css/gcspread.sheets.excel2013white.9.40.20161.0.css" rel="stylesheet" type="text/css" />

    <script src="../../../external/external/jquery-1.8.2.min.js" type="text/javascript"></script>

    <script type="text/javascript" src="../../../external/spreadjs/gcspread.sheets.all.9.40.20161.0.min.js"></script>

    <script id="scriptInit" type="text/javascript">
        /*code_begin*/
        var spreadNS = GcSpread.Sheets;
        $(document).ready(function () {
            var spread = new GcSpread.Sheets.Spread(document.getElementById("ss"), { sheetCount: 2 });
            initSpread(spread);
        });

        function initSpread(spread) {
            spread.newTabVisible(false);
            this.initHorizontalSparkline(spread.sheets[0], "Horizontal");
            this.initVerticalSparkline(spread.sheets[1], "Vertical");
        };

        function initHorizontalSparkline(sheet, name) {
            sheet.isPaintSuspended(true);
            sheet.setName(name);

            sheet.addSpan(0, 0, 1, 4);
            sheet.getCell(0, 0).value("Employee KPI").font("20px Arial").hAlign(spreadNS.HorizontalAlign.center).vAlign(spreadNS.VerticalAlign.center);
            sheet.setValue(1, 0, "Name");
            sheet.setValue(1, 1, "Forecast");
            sheet.setValue(1, 2, "Actuality");
            sheet.setValue(1, 3, "Diagram");
            sheet.getCells(1, 0, 1, 3).foreColor("white").backColor("Accent 4").hAlign(1).vAlign(1);

            sheet.setValue(2, 0, "Employee 1");
            sheet.setValue(2, 1, 6);
            sheet.setValue(2, 2, 6);
            sheet.setValue(3, 0, "Employee 2");
            sheet.setValue(3, 1, 8);
            sheet.setValue(3, 2, 7);
            sheet.setValue(4, 0, "Employee 3");
            sheet.setValue(4, 1, 6);
            sheet.setValue(4, 2, 4);
            sheet.setValue(5, 0, "Employee 4");
            sheet.setValue(5, 1, 7);
            sheet.setValue(5, 2, 9);
            sheet.setValue(6, 0, "Employee 5");
            sheet.setValue(6, 1, 6);
            sheet.setValue(6, 2, 8);
            sheet.setValue(7, 0, "Employee 6");
            sheet.setValue(7, 1, 8);
            sheet.setValue(7, 2, 7);
            sheet.setValue(8, 0, "Settings:");
            sheet.setValue(9, 0, "target");
            sheet.setValue(9, 1, 7);
            sheet.setValue(10, 0, "maxi");
            sheet.setValue(10, 1, 10);
            sheet.setValue(11, 0, "good");
            sheet.setValue(11, 1, 8);
            sheet.setValue(12, 0, "bad");
            sheet.setValue(12, 1, 5);
            sheet.setValue(13, 0, "color scheme");
            sheet.setValue(13, 1, "gray");

            sheet.setFormula(2, 3, '=BULLETSPARKLINE(C3,B10,B11,B12,B13,B3,1,B14');
            sheet.setFormula(3, 3, '=BULLETSPARKLINE(C4,B10,B11,B12,B13,B4,1,B14');
            sheet.setFormula(4, 3, '=BULLETSPARKLINE(C5,B10,B11,B12,B13,B5,1,B14');
            sheet.setFormula(5, 3, '=BULLETSPARKLINE(C6,B10,B11,B12,B13,B6,1,B14');
            sheet.setFormula(6, 3, '=BULLETSPARKLINE(C7,B10,B11,B12,B13,B7,1,B14');
            sheet.setFormula(7, 3, '=BULLETSPARKLINE(C8,B10,B11,B12,B13,B8,1,B14');

            sheet.setRowHeight(0, 30);
            for (var i = 2; i < 8; i++) {
                sheet.setRowHeight(i, 40);
            }
            sheet.setColumnWidth(0, 100);
            sheet.setColumnWidth(1, 100);
            sheet.setColumnWidth(2, 100);
            sheet.setColumnWidth(3, 200);

            sheet.isPaintSuspended(false);
        }

        function initVerticalSparkline(sheet, name) {
            sheet.isPaintSuspended(true);
            sheet.setName(name);

            sheet.addSpan(0, 0, 1, 7);
            sheet.getCell(0, 0).value("Employee KPI").font("20px Arial").hAlign(spreadNS.HorizontalAlign.center).vAlign(spreadNS.VerticalAlign.center);

            sheet.setArray(1, 0, [
                [ "Name", "Employee 1", "Employee 2", "Employee 3", "Employee 4", "Employee 5", "Employee 6" ],
                [ "Forecast", 6, 8, 8, 7, 6, 8 ],
                ["Actuality", 6, 7, 4, 9, 8, 7],
                ["Diagram"]
            ]);

            sheet.getCells(1, 0, 4, 0).foreColor("white").backColor("Accent 4").hAlign(spreadNS.HorizontalAlign.center).vAlign(spreadNS.VerticalAlign.center);

            sheet.setValue(8, 0, "Settings:");
            sheet.setValue(9, 0, "target");
            sheet.setValue(9, 1, 7);
            sheet.setValue(10, 0, "maxi");
            sheet.setValue(10, 1, 10);
            sheet.setValue(11, 0, "good");
            sheet.setValue(11, 1, 8);
            sheet.setValue(12, 0, "bad");
            sheet.setValue(12, 1, 5);
            sheet.setValue(13, 0, "color scheme");
            sheet.setValue(13, 1, "red");

            sheet.setFormula(4, 1, '=BULLETSPARKLINE(B4,B10,B11,B12,B13,B3,1,B14,true');
            sheet.setFormula(4, 2, '=BULLETSPARKLINE(C4,B10,B11,B12,B13,C3,1,B14,true');
            sheet.setFormula(4, 3, '=BULLETSPARKLINE(D4,B10,B11,B12,B13,D3,1,B14,true');
            sheet.setFormula(4, 4, '=BULLETSPARKLINE(E4,B10,B11,B12,B13,E3,1,B14,true');
            sheet.setFormula(4, 5, '=BULLETSPARKLINE(F4,B10,B11,B12,B13,F3,1,B14,true');
            sheet.setFormula(4, 6, '=BULLETSPARKLINE(G4,B10,B11,B12,B13,G3,1,B14,true');

            sheet.setRowHeight(0, 30);
            sheet.setColumnWidth(0, 100);
            for (var i = 1; i < 7; i++) {
                sheet.setColumnWidth(i, 80);
            }
            sheet.setRowHeight(4, 120);

            sheet.isPaintSuspended(false);
        }
        /*code_end*/
    </script>

</head>
<body>
    <div class="sample-turtorial">
        <div id="ss" style="width: 100%; height: 480px; border: 1px solid gray;"></div>
    </div>
</body>
</html>
